<?php

require_once BASE_PATH.'application/models/basedao'.EXT;

class listMailDAO extends baseDAO {

	var $table = 'acymailing_list';
	var $key   = 'listid';
	var $sql   = '';
  
  function __construct()
  {
    parent::__construct();
  }
 
   function _defaultSQL()
   {
      $this->db->where("published = 1",NULL,false);
   }
   
   function validaMail($mail)
   {
      //$this->_defaultSQL();
      $this->table = "acymailing_subscriber";
      $this->db->where("email = '".$mail."'",NULL,false);
      $a = $this->select();
      return count($a);
   }
 
   function getListBoletin()
   {
      $this->_defaultSQL();
      return $this->select();
   } 
 
 
 
   function setUserSub($table,$data,$key)
   {
        $this->db->insert($table, $data);
        $id = $this->getLastId($key,$table);
        return $id;
   }
 
 
 
   function getLastId($key,$table)
  {
	$this->db->select_max($key);
	$this->db->limit(1);
	$query = $this->db->get($table);
	$row = $query->row(); 
  	return $row->{$key};
  }
 

 }  


?>